package com.akina.matchsystem.listener;


import com.akina.matchsystem.contant.CacheKeys;
import com.akina.matchsystem.model.request.CodeRequest;
import com.akina.matchsystem.utils.EmailUtils;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class RabbitMqMail {
    //@Resource
    @Resource
    EmailUtils emailUtils;
    @Resource
    StringRedisTemplate stringRedisTemplate;
    //Template redisTemplate;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("direct.queue1"),
            exchange = @Exchange(name = "akina.direct",type = ExchangeTypes.DIRECT),
            key="mailCode"
    ))
    public void sendEmail(CodeRequest codeRequest ){

         emailUtils.sendCode(codeRequest.getEmail(),codeRequest.getCode());
    }

}
